﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.NumericalIntegration
{
    /// <summary>
    /// Defines the range of an infinity integral.
    /// </summary>
    public enum IntegralRange
    {
        /// <summary>
        /// The integral is defined from -infinity to the specified bound.
        /// </summary>
        MinusInfinityToBound = 0,
        /// <summary>
        /// The integral is defined from the specified bound to +infinity.
        /// </summary>
        BoundToPlusInfinity = 1,
        /// <summary>
        /// The integral is defined from -infinity to +infinity.
        /// </summary>
        MinusInfinityToPlusInfinity = 2
    }

    /// <summary>
    /// This class represents an infinity integral. The integral may specified from -infinity to a 
    /// specified bound, from a specified bound to +infinity or from -infinity to +infinity.
    /// </summary>
    [Serializable]
    public class InfinityIntegral : IInfinityIntegral
    {
        /// <summary>
        /// The bound of the integral which is not infinity.
        /// </summary>
        private int bound;

        /// <summary>
        /// The range of the integral.
        /// </summary>
        private IntegralRange range;

        /// <summary>
        /// The function of the integral.
        /// </summary>
        private IRealFunction function;

        /// <summary>
        /// Initializes a new instance of the <see cref="InfinityIntegral"/> class.
        /// </summary>
        /// <param name="range">The range of the integral.</param>
        /// <param name="function">The function of the integral.</param>
        public InfinityIntegral(IntegralRange range, IRealFunction function)
        {
            this.range = range;
            this.function = function;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InfinityIntegral"/> class.
        /// </summary>
        /// <param name="range">The range of the integral.</param>
        /// <param name="bound">The bound of the integral which is not infinity.</param>
        /// <param name="function">The function of the integral.</param>
        public InfinityIntegral(IntegralRange range, int bound, IRealFunction function)
        {
            this.bound = bound;
            this.range = range;
            this.function = function;
        }

        /// <summary>
        /// Gets or sets the bound of the integral which is not infinity.
        /// </summary>
        /// <value>The bound of the integral which is not infinity.</value>
        public int Bound
        {
            get { return bound; }
            set { bound = value; }
        }

        /// <summary>
        /// Gets or sets the range of the integral.
        /// </summary>
        /// <value>The range of the integral.</value>
        public IntegralRange Range
        {
            get { return range; }
            set { range = value; }
        }

        /// <summary>
        /// Gets or sets the function of the integral.
        /// </summary>
        /// <value>The function of the integral.</value>
        public IRealFunction Function
        {
            get { return function; }
            set { function = value; }
        }
    }
}